package vn.aptech.leaveManagementSystem.business.model;

import java.sql.CallableStatement;
import java.sql.Date;
import java.sql.ResultSet;
import java.sql.SQLException;

import vn.aptech.leaveManagementSystem.dao.DBManager;

public class Reports extends DBManager{
	
	public ResultSet getReportApplicationsIndividual(int idEmp, Date fromDate, Date toDate) throws SQLException
	//[Application].*,
	//FirstName,LastName,Gender,Birthday,JoinDate,
	//IDDepartment,DepartmentName,IDPosition,PositionName
	//NumDaysLeave
	{
		getConn();
		String sql="{Call sp_getReportApplicationsIndividual(?,?,?)}";
		CallableStatement cs=conn.prepareCall(sql);
		cs.setInt(1, idEmp);
		cs.setDate(2, fromDate);
		cs.setDate(3, toDate);
		return cs.executeQuery();
	}
	
	
	public ResultSet getReportTotalDaysLeaveIndividual(int idEmp, Date fromDate, Date toDate) throws SQLException
	//EmpID,FirstName,LastName,Gender,Birthday,JoinDate,
	//IDDepartment,DepartmentName,
	//IDPosition,PositionName,
	//SumDaysLeave
	{
		getConn();
		String sql="{Call sp_getReportTotalDaysLeaveIndividual(?,?,?)}";
		CallableStatement cs=conn.prepareCall(sql);
		cs.setInt(1, idEmp);
		cs.setDate(2, fromDate);
		cs.setDate(3, toDate);
		return cs.executeQuery();
	}
	
	public ResultSet getReportTotalDaysLeaveDepartment(int idDep,Date fromDate, Date toDate) throws SQLException
	//EmpID,FirstName,LastName,Gender,Birthday,JoinDate,
	//IDDepartment,DepartmentName,
	//IDPosition,PositionName,
	//SumDaysLeave
	{
		getConn();
		String sql="{Call sp_getReportTotalDaysLeaveDepartment(?,?,?)}";
		CallableStatement cs=conn.prepareCall(sql);
		cs.setInt(1, idDep);
		cs.setDate(2, fromDate);
		cs.setDate(3, toDate);
		return cs.executeQuery();
	}
	
	public ResultSet getReportTotalDaysLeaveCompany(Date fromDate, Date toDate) throws SQLException
	//EmpID,FirstName,LastName,Gender,Birthday,JoinDate,
	//IDDepartment,DepartmentName,
	//IDPosition,PositionName,
	//SumDaysLeave
	{
		getConn();
		String sql="{Call sp_getReportTotalDaysLeaveCompany(?,?)}";
		CallableStatement cs=conn.prepareCall(sql);
		cs.setDate(1, fromDate);
		cs.setDate(2, toDate);
		return cs.executeQuery();
	}
}
